import Vue from "vue";
import VeeValidate, { Validator } from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN";
Validator.localize("zh_CN", zh_CN);
Vue.use(VeeValidate);
Validator.extend("required", {
  getMessage: (field) => field + " 不能为空!",
  validate: (value) => value,
});
Validator.extend("phone", {
  getMessage: (field) => field + " 格式错误!",
  validate: (value) => /^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(value),
});
Validator.extend("code", {
  getMessage: (field) => field + " 格式错误!",
  validate: (value) => /^\d{6}$/.test(value),
});
Validator.extend("pwd", {
  getMessage: (field) => field + " 格式错误!",
  validate: (value) => /^\w{6,21}$/.test(value),
});
Validator.extend("pwdConfirm", {
  getMessage: (field) => field + " 不一致!",
  validate: (value, args) => value === args[0],
});
Validator.extend("agree", {
  getMessage: (field) => field + " 必须勾选!",
  validate: (value) => value,
});
